<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>中心医院医疗服务系统</title>
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/icon.css"/>">
<script type="text/javascript" src="<c:url value="/js/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/easyui-lang-zh_CN.js"/>"></script>

<script type="text/javascript" src="<c:url value="/js/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/easyui-lang-zh_CN.js"/>"></script>
</head>
<body>
<style>
	* {
		font-size: 12px;
	}
	
	.lmb-hc-item{
		margin-top: 5px;
	}
</style>
<script type="text/javascript">
	
	
	$(function(){	
		$("#lmb-Cousumable-add").linkbutton({onClick: function(){
			$('#lmb-Cousumable-win-add').window({'title': "录入耗材"});
			$('#lmb-Cousumable-form-add').form("clear");
			$("#lmb-Cousumable-win-add").window("open");
		}});
			
		//提交添加/编辑学生的请求
		$("#lmb—Cousumable-btn-ok").linkbutton({onClick: function(){
			var title = $('#lmb-Cousumable-win-add').window("options").title;
			var url = (title == '录入耗材' ? 'to_lmb_addCousumable' : 'to_lmb_editCousumable');		
			$('#lmb-Cousumable-form-add').form('submit', {
				url: url,
			    onSubmit: function(){
			    	//验证
			    	return $(this).form("validate");
			    },
			    success:function(data){
			    	var json = eval("(" + data + ")");
					$.messager.alert("提示", json.reason);
					//关闭窗口
					$('#lmb-Cousumable-win-add').window('close');
					//重新加载数据
					$("#tb-LmbCousumable").datagrid("reload");
					$(this).form("clear");
			    }
			});
		}});
		
		//
		$('#lmb-Cousumable-search').searchbox({
		    searcher:function(value,name){
		    	$("#tb-LmbCousumable").datagrid({
		    		url: 'to_lmb_findLmbConsumableByCname', 
		    		method: 'post', 
		    		queryParams: {
		    			cname: value,
		    			page:1, 
		    			rows:10
		    		}});
		    }
		});
		
		// 刷新
		$("#lmb-Cousumable-reload").linkbutton({onClick:function(){
			$("#tb-LmbCousumable").datagrid({
	    		url: 'to_lmb_findAllLmbConsumable', 
	    		method: 'get',
	    		page:1, 
    			rows:10
	    	});
		}});
		
		//耗材修改
		$("#lmb-Cousumable-edit").linkbutton({onClick: function(){
			var rows = $("#tb-LmbCousumable").datagrid("getSelections");
			if(rows.length == 1){
				$('#lmb-Cousumable-win-add').window({'title': "编辑耗材"});
				$('#lmb-Cousumable-win-add').window("open");
				//初始化表单
				var  cId= rows[0].cId;
				$.getJSON("to_lmb_findCousumableById", {"cId": cId}, function(data){
					$("#lmb-Cousumable-win-add").form("load", data);
					//$("#cc").combogrid({value: data.classz.cid});
				});
				
			}else{
				$.messager.alert("提示", "只能选择一条记录，您目前选择了" + rows.length + "条!");
			}
			
		}});
		
	});
	

</script>
<table id="tb-LmbCousumable" class="easyui-datagrid" 
		data-options="
			url:'to_lmb_findAllLmbConsumable',
			fitColumns:true,fit:true,
			pagination: true,
			pageSize: 5,
			pageList: [5, 10, 15, 20],
			rownumbers: true,
			toolbar: '#tb_Cousumable',
			border:false
			">
		<thead>
			<tr>	
				<th data-options="field:'',checkbox:true"></th>									
				<th data-options="field:'cId',width:'25%'">耗材编号</th>
				<th data-options="field:'cName',width:'30%'">耗材名称</th>
				<th data-options="field:'cMorms',width:'20%'">单位</th>
			</tr>
		</thead>
	</table>
	
	<div id="tb_Cousumable">
		<a id="lmb-Cousumable-add" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">添加</a>
		<a id="lmb-Cousumable-edit" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">修改</a>
		<a id="lmb-Cousumable-reload" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true">刷新</a>
		<input id="lmb-Cousumable-search" class="easyui-searchbox" data-options="menu: '#lmb-Cousumable-mm', width: 220, prompt: '请输入关键字'"/>
	</div>
	
	<div id="lmb-Cousumable-mm" style="width:120px">
		<div data-options="name:'hcmc'">耗材名称</div>
	</div>
	
	<div id="lmb-Cousumable-win-add" class="easyui-window" title="录入耗材" data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-save',closed: true" style="width:360px;height:240px;padding:5px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center'" style="padding:10px;">
				<form id="lmb-Cousumable-form-add" method="post">
					<div id="lmb_hcbh"><input name="cId" class="easyui-textbox"  data-options="label: '耗材编号', width: 200,readonly:true"></div>
					<div class="lmb-hc-item"><input name="cName" class="easyui-textbox" data-options="label: '耗材名称', width: 200"></div>
      				<div class="lmb-hc-item">
      					<select name="cMorms" class="easyui-combobox" data-options="label: '单位',width: 200,panelHeight: 'auto'">
           					<option value="盒">盒</option>
           					<option value="包">包</option>
           					<option value="卷">卷</option>
           					<option value="个">个</option>
           					<option value="双">双</option>
           					<option value="袋">袋</option>
           					<option value="瓶">瓶</option>
           					<option value="箱">箱</option>
           					<option value="片">片</option>
           					<option value="支">支</option>
           					<option value="板">板</option>
           					
      					</select>
      				</div>					
				</form>
			</div>
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a id="lmb—Cousumable-btn-ok" class="easyui-linkbutton" data-options="iconCls:'icon-ok', plain:true" >确定</a>
				<a class="easyui-linkbutton" data-options="iconCls:'icon-cancel', plain:true" href="javascript:$('#lmb-Cousumable-win-add').window('close');" onclick="">取消</a>
			</div>
		</div>
	</div>	
</body>
</html>